<?php

class models_oms_mapper {

    private $_db;
    private $_cache;

    public function __construct($db, $cache) {
        $this->_db = $db;
        $this->_cache = $cache;
    }

    public function get_all_status_oms() {

        $all_ims_order_status = $this->_db->query("SELECT id_sales_order_item_status, name FROM ims_sales_order_item_status", null, false);

        $all_status_mapper = $this->_db->query("
			SELECT fk_id_sales_order_item_status, d.`text` FROM `status_display` d
			INNER JOIN `status_oms_mapper` som ON som.`fk_id_status_display` = d.`id_status_display`
		", null, true);

        $status_join = array();

        foreach ($all_ims_order_status as $order_status) {
            foreach ($all_status_mapper as $status_mapper) {
                if (isset($order_status['id_sales_order_item_status']) &&
                        isset($status_mapper['fk_id_sales_order_item_status']) &&
                        $order_status['id_sales_order_item_status'] == $status_mapper['fk_id_sales_order_item_status']) {

                    $status_join[trim($order_status['name'])] = trim($status_mapper['text']);
                }
            }
        }

        $exce = $this->_db->getPDOException();
        if ($exce) {
            throw new $exce;
        }

        return $status_join;
    }

}

?>
